package cn.wolfcode.education.service.impl;

import cn.wolfcode.education.domain.Dept;
import cn.wolfcode.education.mapper.DeptMapper;
import cn.wolfcode.education.query.QueryObject;
import cn.wolfcode.education.service.IDeptService;
import cn.wolfcode.education.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements IDeptService {

    @Autowired
    private DeptMapper deptMapper;


    public List<Dept> listAll() {
        return deptMapper.selectAll();
    }



    public void save(Dept dept) {
        deptMapper.insert(dept);

    }

    public void update(Dept dept) {

    }

    public void delete(Long id) {

        deptMapper.updateStateById(id, Dept.STATE_LOCK);
    }

    public PageResult list(QueryObject qo) {
        Integer totals = deptMapper.queryForCount(qo);
        if(totals == 0){
            return new PageResult();
        }
        List list = deptMapper.queryForList(qo);
        return new PageResult(totals,list);
    }



}
